<?php
session_start();

require_once("../database.include.php");

	$username=$_GET["username"];
	$inviteuser=$_GET["inviteUser"];
	$groupname=$_GET["selinviteGroup"];
	$encgroupprivkey=$_GET["encGroupPrivKey"];
	
	$conn->beginTransaction();
	try {
			
		$stmt = $conn->prepare('INSERT INTO `group_invitation` (inviting_user_name, invited_user_name, group_name, encrypted_group_private_key) VALUES(?, ?, ?, ?)');
		$insertGroupInviteSuccess = $stmt->execute( array( $username, $inviteuser, $groupname, $encgroupprivkey) );
		$conn->commit();
		echo "<br/>Success on inserting into group_invitation: " . $groupname . ", " . $inviteuser . ", " . $username . ", " .$encgroupprivkey;
		return "<br/>Success on inserting into group_invitation: " . $groupname . ", " . $inviteuser . ", " . $username . ", " .$encgroupprivkey;
	}
	catch(Exception $err) 
	{
		$conn->rollBack();
		echo "<br/>Internal failure adding to group: " . $groupname . ", " . $inviteuser . ", " . $username . ", " .$encgroupprivkey;
		return "Internal failure adding to group: " . $groupname . ", " . $inviteuser . ", " . $username . ", " .$encgroupprivkey;	
	}
?>